/**
 * @File Name: Common.h
 * @brief  
 * @Author : LiWanglin email:lwl510ll@163.com
 * @Version : 1.0
 * @Creat Date : 2023-12-02
 * 
 * @copyright Copyright (c) 2023 LiWanglin
 */

#ifndef COMMON_COMMON_H
#define COMMON_COMMON_H

#include <cstdint>

typedef int int32_t;

typedef unsigned int uint32_t;

#define GET_SOCKET_ADDRESS      0x01010101
#define GET_SOCKET_PORT         0x01010102

#define SET_SOCKET_ADDRESS      0x01010201
#define SET_SOCKET_PORT         0x01010202

enum CMResult {
    CM_OK = 0,
    CM_NULL_POINT = -1,
    CM_OPEN_FILE_ERROR = -2,
    CM_CREAT_SOCKET_FAILED = -3,
    CM_BIND_SOCKET_FAILED = -4,
    CM_LISTEN_SOCKET_FAILED = -5,
    CM_CONFIG_NO_EXIST = -6,
    CM_CONFIG_FILE_ERR = -7,
    CM_JSON_PRASE_FAILED = -8,
    CM_SOCKET_ERROR = -9,
    CM_SEND_ERROR = -10,
    CM_RECV_ERROR = -11,
    CM_DATA_ERROR = -12,
    CM_FIND_H264_HEADER_ERROR = -13,
    CM_ARG_ERROR = -14,
    CM_SOCKET_LISTEN_ERR = -15
};

class CMFunc 
{
public:
    static int create_udp_socket(int *fd, char *ip, uint16_t port);
    static int create_tcp_socket(int *fd, char *ip, uint16_t port, bool listen_enable);
};


#endif  /* COMMON_COMMON_H */ 